package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：bigdata
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：2016/10/20 10:32
 * 修改备注：
 * ================================================
 */

public class BusinessDataMall {

    /**
     * 数据商城列表
     *
     * @param activity
     * @param offset   页码
     * @param limit    行数
     * @param keyWords 搜索的关键词
     * @param code     商品类型编码
     * @param handler
     */
    public static void datamartlistcontent(Activity activity, String offset, String limit,
                                           String keyWords, String code, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("offset", offset);
        params.put("limit", limit);
        params.put("keyWords", keyWords);
        params.put("code", code);

        OkHttpUtil.post(activity, URL.URL_DATA_MART_LIST_CONTENT, "", params, handler,
                MSG.MSG_DATA_MART_LIST_CONTENT_SUCCESS, MSG.MSG_DATA_MART_LIST_CONTENT_FIELD);

    }

    /**
     * 数据商城商品详情
     *
     * @param activity
     * @param commodityId 商品ID
     * @param handler
     */
    public static void productdetails(Activity activity, String commodityId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("commodityId", commodityId);
        OkHttpUtil.post(activity, URL.URL_PRODUCT_DETAILS, "", params, handler,
                MSG.MSG_PRODUCT_DETAILS_SUCCESS, MSG.MSG_PRODUCT_DETAILS_FIELD);

    }

    /**
     * 数据商城商品分享(url后传入renderType=pl_ercode)
     *
     * @param activity
     * @param commodityId 商品ID
     * @param handler
     */
    public static void productsShare(Activity activity, String commodityId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("commodityId", commodityId);
        params.put("renderType", "pl_ercode");
        OkHttpUtil.post(activity, URL.URL_PRODUCT_DETAILS, "", params, handler,
                MSG.MSG_PRODUCT_DETAILS_SUCCESS, MSG.MSG_PRODUCT_DETAILS_FIELD);

    }


    /**
     * 数据商城商品类型
     *
     * @param activity
     * @param typeCode 传入的商品类型编号 不传则返回所有集合
     * @param handler
     */
    public static void dataMartList(Activity activity, String typeCode, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("typeCode", typeCode);
        OkHttpUtil.post(activity, URL.URL_DATA_MART_LIST_URL, "", params, handler,
                MSG.MSG_DATA_MART_LIST_SUCCESS, MSG.MSG_DATA_MART_LIST_FIELD);

    }

}
